load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_dep", "react_native_target", "react_native_xplat_dep", "rn_android_library", "rn_xplat_cxx_library")

rn_android_library(
    name = "instrumentation",
    srcs = ["HermesMemoryDumper.java"],
    visibility = [
        "PUBLIC",
    ],
)

rn_android_library(
    name = "hermes_samplingprofiler",
    srcs = ["HermesSamplingProfiler.java"],
    visibility = ["PUBLIC"],
    deps = [
        react_native_dep("java/com/facebook/proguard/annotations:annotations"),
        react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
        react_native_dep("libraries/fbjni:java"),
        ":jni_hermes_samplingprofiler",
    ],
)

rn_xplat_cxx_library(
    name = "jni_hermes_samplingprofiler",
    srcs = [
        "HermesSamplingProfiler.cpp",
        "OnLoad.cpp",
    ],
    headers = ["HermesSamplingProfiler.h"],
    header_namespace = "",
    compiler_flags = ["-fexceptions"],
    platforms = ANDROID,
    soname = "libjsijniprofiler.$(ext)",
    visibility = [
        react_native_dep("java/com/facebook/jsi:jsi"),
    ],
    deps = [
        react_native_target("jni/react/jni:jni"),
        FBJNI_TARGET,
        react_native_xplat_dep("hermes/API:HermesAPI"),
    ],
)
